<?php 
function changedate($dd){
			//$yr =array();
			$date = split("-",$dd);
			$month = array("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
		    $mon=  $date[1]+0;
			$newDate = $month[$mon]." ". $date[2].", ".$date[0]; 
			return $newDate;
	}
function changedateTime($dd){
			//$yr =array();
			$date = split("-",$dd);
			$month = array("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
		    $mon=  $date[1]+0;
			$day = substr($date[2],0,2);
			$time = substr($date[2],2);
			$newDate = $month[$mon]." ". $day.", ".$date[0] ." ". substr($time,0,6); 
			return $newDate;
	}
	
function sendmail($sender,$receiver,$message,$subject)
{
	 $headers="From: $sender <$sender@mygilbertbooks.com>";
	 $headers.= "MIME-Version: 1.0\n" ;
     $headers.= "Content-Type: text/html; charset=\"iso-8859-1\"\n"; 
		
	mail($receiver,$GLOBALS['METROINITIALS']-$subject ,$message,$headers);
}

function highLightResult($search,$find){
	$HIGHLIGHT_SPAN_START="<span class='highlight'>";
	$HIGHLIGHT_SPAN_END="</span>";
	$HIGHLIGHT =  $HIGHLIGHT_SPAN_START.$find.$HIGHLIGHT_SPAN_END;
	$stringBuffer ="";
	$msplit = split(strtolower($find),  strtolower($search));
	
	for($i=0;$i<count($msplit);$i++){
		@$str = strpos($search,$msplit[$i]."");
		$stringBuffer.=$msplit[$i].$HIGHLIGHT;
	}
	return $stringBuffer;
} 
	$page="welcome";
	if(isset($_GET['page']))
	{
		$page = $_GET['page'];
	}
	
	
	if(is_file("pages/".$page."_view.php"))
	{
		$pageFile ="pages/page.php";
	}else
		$pageFile ="pages/welcome.php";


function createThumb($sourceimg, $preferedSize){
$mainImage = imagecreatefromjpeg($sourceimg);

$mainWidth = imagesx($mainImage);
$mainHeight = imagesy ($mainImage) ;
if($mainWidth<$preferedSize || $mainHeight <$preferedSize)
{
	$thumbWidth = $mainWidth;
	$thumbHeight = $mainHeight;
}else { 
	
	$thumbHeight = intval(($mainHeight *$preferedSize) /$mainWidth);
	$thumbWidth = $preferedSize;
}
$myThumbnail = imagecreatetruecolor($thumbWidth, $thumbHeight);

imagecopyresampled($myThumbnail, $mainImage, 0, 0,0,0, $thumbWidth,$thumbHeight, $mainWidth, $mainHeight);
return  $myThumbnail;


}
?>